package jmm;

import java.util.concurrent.atomic.AtomicInteger;

public class Novolatile implements Runnable{


    volatile  int a =0;
    AtomicInteger realA = new AtomicInteger();


    public static void main(String[] args) throws InterruptedException {
        Novolatile novolatile = new Novolatile();

        Thread t1 = new Thread(novolatile);
        Thread t2 = new Thread(novolatile);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(novolatile.a);
        System.out.println(novolatile.realA.get());
    }

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            a++;
            realA.incrementAndGet();
        }
    }
}
